﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace ClickNET.IO
{
    public class ImageEntity : FileEntity
    {
        public ImageEntity() { }

        public ImageEntity(string imagePath) : base(imagePath) { }

        /// <summary>
        /// Gets a GDI+ Bitmap object
        /// </summary>
        /// <returns></returns>
        public Bitmap GetBitmap()
        {
            using (Stream imgStream = new FileStream(this.Path, FileMode.Open, FileAccess.Read))
            {
                return new Bitmap(imgStream);
            }
        }

        protected internal override void Load()
        {
            base.Load();

            if (File.Exists(this.Path))
            {
                //using (Bitmap bmp = this.GetBitmap())
                //{
                //    this.Height = bmp.Height;
                //    this.Width = bmp.Width;
                //}
            }
        }

        [XmlElement]
        public double Width { get; set; }

        [XmlElement]
        public double Height { get; set; }
    }
}
